home *** CD-ROM | disk | FTP | other *** search
-
-
-
- FFFFOOOOPPPPEEEENNNN((((3333SSSS)))) FFFFOOOOPPPPEEEENNNN((((3333SSSS))))
-
-
-
- NNNNAAAAMMMMEEEE
- fopen, freopen, fdopen - open a stream
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
-
- FFFFIIIILLLLEEEE ****ffffooooppppeeeennnn ((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffiiiilllleeeennnnaaaammmmeeee,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ttttyyyyppppeeee))));;;;
-
- FFFFIIIILLLLEEEE ****ffffrrrreeeeooooppppeeeennnn ((((ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ffffiiiilllleeeennnnaaaammmmeeee,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ttttyyyyppppeeee,,,, FFFFIIIILLLLEEEE ****ssssttttrrrreeeeaaaammmm))));;;;
-
- FFFFIIIILLLLEEEE ****ffffddddooooppppeeeennnn ((((iiiinnnntttt ffffiiiillllddddeeeessss,,,, ccccoooonnnnsssstttt cccchhhhaaaarrrr ****ttttyyyyppppeeee))));;;;
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- _f_o_p_e_n opens the file named by _f_i_l_e_n_a_m_e and associates a _s_t_r_e_a_m with it.
- _f_o_p_e_n returns a pointer to the FILE structure associated with the _s_t_r_e_a_m.
-
- _f_i_l_e_n_a_m_e points to a character string that contains the name of the file
- to be opened.
-
- _t_y_p_e is a character string. The initial portion of _t_y_p_e must consist of
- one of the following character sequences:
-
- rrrr _o_r rrrrbbbb open for reading
-
- wwww _o_r wwwwbbbb truncate or create for writing
-
- aaaa _o_r aaaabbbb append: open for writing at end of file or create for
- writing
-
- rrrr++++,rrrr++++bbbb _o_r rrrrbbbb++++ open for update (reading and writing)
-
- wwww++++,wwww++++bbbb _o_r wwwwbbbb++++ truncate or create for update
-
- aaaa++++,aaaa++++bbbb _o_r aaaabbbb++++ append: open for update at end-of-file or create for
- update
- As this implementation does not distinguish between _b_i_n_a_r_y and _t_e_x_t
- files, the character bbbb in the string _t_y_p_e, (which is used to indicate
- that the file being opened is a _b_i_n_a_r_y file) is inconsequential.
-
- Opening a file for reading (when rrrr is the first character of _t_y_p_e) will
- fail if the file does not exist or is unreadable.
-
- When a file is opened for update (when ++++ appears as the second (or third,
- in the case of _f_o_p_e_n or _f_r_e_o_p_e_n) character of _t_y_p_e) both input and output
- may be done on the resulting _s_t_r_e_a_m. However, output may not be directly
- followed by input without an intervening _f_s_e_e_k, _f_s_e_t_p_o_s, or _r_e_w_i_n_d.
- Similarly, input may not be directly followed by output without an
- intervening call to one of these functions, unless the input operation
- left the file positioned at end-of-file. (See note under BUGS below.)
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- FFFFOOOOPPPPEEEENNNN((((3333SSSS)))) FFFFOOOOPPPPEEEENNNN((((3333SSSS))))
-
-
-
- When a file is opened for append (i.e., when _t_y_p_e is aaaa, aaaabbbb, aaaa++++bbbb, aaaabbbb++++ or
- aaaa++++), it is impossible to overwrite information already in the file.
- _f_s_e_e_k may be used to reposition the file pointer to any position in the
- file, but when output is written to the file, the current file pointer is
- disregarded. All output is written at the end of the file and causes the
- file pointer to be repositioned at the end of the output. If two
- separate processes open the same file for append, each process may write
- freely to the file without fear of destroying output being written by the
- other. The output from the two processes will be intermixed in the file
- in the order in which it is written.
-
- _f_r_e_o_p_e_n substitutes the named file in place of the open _s_t_r_e_a_m. An
- attempt is made to close the original _s_t_r_e_a_m, using _f_c_l_o_s_e(3s). If this
- close attempt is unsuccessful, the failure is ignored. _f_r_e_o_p_e_n then
- attempts to open the file indicated by _f_i_l_e_n_a_m_e, returning the result.
- The character string _t_y_p_e must have the same form as for _f_o_p_e_n. If the
- open is successful, the end-of-file and error indicators for _s_t_r_e_a_m are
- cleared.
-
- _f_r_e_o_p_e_n is typically used to attach the preopened _s_t_r_e_a_m_s associated with
- ssssttttddddiiiinnnn, ssssttttddddoooouuuutttt and ssssttttddddeeeerrrrrrrr to other files.
-
- _f_d_o_p_e_n associates a stream with a file descriptor. File descriptors are
- obtained from _o_p_e_n, _d_u_p, _c_r_e_a_t, or _p_i_p_e(2), which open files but do not
- initialize a stream, which is the object manipulated by many of the
- Section 3S library routines. _f_d_o_p_e_n initializes a stream for the open
- file descriptor _f_i_l_d_e_s, and returns a pointer to the corresponding FILE
- structure. The character string _t_y_p_e has the same form as that for
- _f_o_p_e_n, with the exception that the (superfluous) binary file
- specification character bbbb, is not allowed. (This restricts the initial
- portion of _t_y_p_e to one of rrrr, wwww, aaaa, rrrr++++, wwww++++, or aaaa++++.) The _t_y_p_e specified
- for the stream must agree with the mode of the open file indicated by
- _f_i_l_d_e_s (see _o_p_e_n(2)).
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- creat(2), close(2), dup(2), open(2), pipe(2), write(2), fclose(3S),
- fseek(3S), setbuf(3s), stdio(3S).
-
- DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
- _f_o_p_e_n, _f_d_o_p_e_n, and _f_r_e_o_p_e_n return a NULL pointer on failure.
-
- Depending on which ABI a program is compiled in, there may be a limit on
- the number of open _s_t_d_i_o streams, or a limit on which file descriptors
- may be associated with _s_t_d_i_o streams. When compiling in nnnn33332222 or nnnn66664444
- modes, there are no limits, however in oooo33332222 mode the functions _f_o_p_e_n or
- _f_d_o_p_e_n may fail and not set _e_r_r_n_o if there are no free _s_t_d_i_o streams. No
- more than 255 files may be opened via _f_o_p_e_n, and only file descriptors 0
- through 255 are valid with _s_t_d_i_o streams.
-
- In oooo33332222 mode file descriptors used by _f_d_o_p_e_n must be less than 255.
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- FFFFOOOOPPPPEEEENNNN((((3333SSSS)))) FFFFOOOOPPPPEEEENNNN((((3333SSSS))))
-
-
-
- BBBBUUUUGGGGSSSS
- When operating on a file opened for update on which the last operation
- was output, an input operation may be performed if there is an
- intervening call to a file positioning function. An input operation
- should also be possible under these circumstances if an intervening call
- is made to _f_f_l_u_s_h. If this sequence of operations (i.e., output, _f_f_l_u_s_h,
- input) is performed, however, the input operation fails with the
- misleading error EEEEBBBBAAAADDDDFFFF.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-